const http = require('http')

http.createServer((request, response) => {
    let body = [];
    request.on('error', err => {
        console.error(err)
    }).on('data', chunk => {
        // 在我使用调试的时候，The "list[0]" argument must be an instance of Buffer or Uint8Array. Received type string ('name=winter') 
        // 我直接传入chunk就不会出现问题
        body.push(chunk)
    }).on('end', () => {
        // body =  (Buffer.concat([Buffer.from(body.toString())])).toString();
        body = Buffer.concat(body).toString()
        console.log("body: ", body)
        response.writeHead(200, {'Content-Type': 'text/html'});
        response.end(' Hello World\n', );
    })
}).listen(8088)

console.log("server started");
